home *** CD-ROM | disk | FTP | other *** search
- Path: news.texas.net!usenet
- From: Michael Douglass <mikedoug@texas.net>
- Newsgroups: comp.lang.c
- Subject: Re: simple code, argc, argv, strcmp()
- Date: Tue, 06 Feb 1996 10:06:15 -0600
- Organization: Texas Networking, Inc.
- Message-ID: <31177C77.167EB0E7@texas.net>
- References: <11f7cc$17261a.3b3@daprez> <4etj7c$bma@news.iag.net> <fcusack-0202961621470001@mudskipper.cac.psu.edu>
- NNTP-Posting-Host: millenium.texas.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; SunOS 4.1.4 sun4m)
-
- > > >int main (int argc, char **argv) {
- > > >
- > > > void Usage (void);
- > > > void Encode (int, char **);
- > > > void Decode (int, char **);
- > > >
- > > > if (!strcmp(argv[1],"-d") || !strcmp(argv[1],"-e")) {
- > > > Usage();
- > > > }
- > > <snip>
-
- > argv[1] is always guaranteed to exist. It is simply NULL if there were no
- > arguments.
-
- Even if this is so... You still do *not* want to call strcmp with a NULL pointer
- now do we? Does that not make your argument moot, and make the previous point
- that you should always check argc to make sure that you *have* at least one argument
- a very good argument?
-
- --
- Michael Douglass
- Texas Networking, Inc.
-
- "I didn't change a thing and from the moment I didn't change it,
- it doesn't work anymore." -- Anonymous
-